package top.layne.cloud.tsf.zuul.filter;

import com.netflix.zuul.ZuulFilter;
import com.netflix.zuul.exception.ZuulException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Configuration;

import static org.springframework.cloud.netflix.zuul.filters.support.FilterConstants.PRE_TYPE;

/**
 * @author : layne
 * @Date: 2020/7/24
 * @Time: 18:19
 * Description:
 */
@Configuration
public class TestFilter extends ZuulFilter {
    private static final Logger LOGGER = LoggerFactory.getLogger(TestFilter.class);


    @Override
    public String filterType() {
        return PRE_TYPE;
    }

    @Override
    public int filterOrder() {
        return 0;
    }

    @Override
    public boolean shouldFilter() {
        // 过滤器是否应该执行， true:表示应该执行  false:表示跳过这个过滤器执行
        return true;
    }

    @Override
    public Object run() throws ZuulException {
        System.out.println(">>>>>Enter zuul gateway ");
        LOGGER.info(">>>>>Enter zuul gateway ");
        return null;
    }
}
